Crate json_syntax
source ·Expand description
This library provides a strict JSON parser as defined by
RFC 8259 and
ECMA-404.
It is built on the locspan
library
so as to keep track of the position of each JSON value in the parsed
document.
Features
- Strict implementation of RFC 8259 and ECMA-404.
- No stack overflow, your memory is the limit.
- Numbers are stored in lexical form thanks to the
json-number
crate, their precision is not limited. - Duplicate values are preserved. A JSON object is just a list of entries, in the order of definition.
- Strings are stored on the stack whenever possible, thanks to the
smallstr
crate. - The parser is configurable to accept documents that do not strictly adhere to the standard.
- Highly configurable printing methods.
- Macro to build any value statically.
- JSON Canonicalization Scheme implementation (RFC 8785)
enabled with the
canonicalization
feature. serde
support (by enabling theserde
feature).- Conversion from/to
serde_json::Value
(by enabling theserde_json
feature). - Thoroughly tested.
Usage
use std::fs;
use json_syntax::{Value, Parse, Print};
let filename = "tests/inputs/y_structure_500_nested_arrays.json";
let input = fs::read_to_string(filename).unwrap();
let mut value = Value::parse_str(&input, |span| span).expect("parse error");
println!("value: {}", value.pretty_print());
Re-exports
Modules
Macros
- Constructs a
Loc<json_syntax::Value, (), ()>
from a JSON literal.
Structs
- Lexical JSON number.
- Wrapper to view a value without considering the order of the objects entries.
Enums
- Value kind.
- Value.
Constants
- Number buffer stack capacity.
- String stack capacity.
Traits
Type Definitions
- Array.
- Value wrapped inside a
locspan::Meta
container. - Number buffer.
- String.